package com.fy.common.exception;

import com.fy.common.enums.ErrorType;
import com.fy.common.spring.I18nHelper;
import lombok.Data;

@Data
public class BusinessException extends RuntimeException {

    private ErrorType errorType;

    private String[] param;



    public BusinessException(ErrorType errorType) {
        super(I18nHelper.getMessage(errorType.getErrorKey()));
        this.errorType = errorType;
    }

    public BusinessException(ErrorType errorType, String[] param) {
        super(I18nHelper.getMessage(errorType.getErrorKey()));
        this.errorType = errorType;
        this.param = param;
    }

    public BusinessException(ErrorType errorType, Throwable cause) {
        super(I18nHelper.getMessage(errorType.getErrorKey()), cause);
        this.errorType = errorType;
    }

    public ErrorType getErrorType() {
        return errorType;
    }

    public void setErrorType(ErrorType errorType) {
        this.errorType = errorType;
    }

    public String[] getParam() {
        return param;
    }

    public void setParam(String[] param) {
        this.param = param;
    }
}
